package com.ws.components.loader
{
	import flash.net.URLLoaderDataFormat;
	
	public class LoaderFactory
	{
		public static function createLoader(aUrl:String):ILoader{
			var loader:ILoader;
			switch(getType(aUrl)){				
				case '.swf':
				case '.jpg':
				case '.gif':
				case '.png':
					loader=new PictureLoader(aUrl);
					break;
				case '.txt':
				case '.log':
					loader=new NorLoader(aUrl,URLLoaderDataFormat.TEXT);
					break;
				default:
					loader=new NorLoader(aUrl,URLLoaderDataFormat.BINARY);
					break;
			}
			return loader;
		}
		
		private static function getType(url:String):String{
			var reg:RegExp =new RegExp(/\.\w{3}$/);
			var str:String = reg.exec(url);
			return str;
		}
	}
}